package com.ruoyi.hqfinance.service.impl;

import com.github.pagehelper.PageHelper;
import com.ruoyi.hqfinance.domain.HqBillCollect;
import com.ruoyi.hqfinance.domain.HqBillData;
import com.ruoyi.hqfinance.domain.HqBillDataShow;
import com.ruoyi.hqfinance.domain.HqBillNearlySevenDay;
import com.ruoyi.hqfinance.domain.vo.HqBillCollectVo;
import com.ruoyi.hqfinance.domain.vo.HqBillDataShowVo;
import com.ruoyi.hqfinance.mapper.HqBillCollectMapper;
import com.ruoyi.hqfinance.mapper.HqBillDataShowMapper;
import com.ruoyi.hqfinance.mapper.HqBillNearlySevenDayMapper;
import com.ruoyi.hqfinance.service.HqBillCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HqBillCollectServiceImpl implements HqBillCollectService {
    @Autowired
    private HqBillCollectMapper hqBillCollectMapper;
    @Autowired
    private HqBillDataShowMapper hqBillDataShowMapper;
    @Autowired
    private HqBillNearlySevenDayMapper hqBillNearlySevenDayMapper;
    @Override
    public List<HqBillCollect> collect(HqBillCollectVo hqBillCollectVo) {
        PageHelper.startPage(hqBillCollectVo.getPageDate());
        List<HqBillCollect> billCollectList = hqBillCollectMapper.collect(hqBillCollectVo);
        for (HqBillCollect hqBillCollect : billCollectList){
            if (hqBillCollect != null) {
                hqBillCollect.setCollectDate(hqBillCollectVo.getStartTime() + "至" + hqBillCollectVo.getEndTime());
            }
        }
        return billCollectList;
    }

    @Override
    public List<HqBillDataShow> billDataShow(HqBillDataShowVo hqBillDataShowVo) {
        return hqBillDataShowMapper.billDataShow(hqBillDataShowVo);
    }

    @Override
    public List<HqBillNearlySevenDay> nearlySevenDay(String costBigKind) {
        return hqBillNearlySevenDayMapper.nearlySevenDay(costBigKind);
    }

    @Override
    public HqBillData data(HqBillDataShowVo vo) {
        HqBillData data = new HqBillData();
        data.setCard(hqBillDataShowMapper.billDataShow(vo));
        data.setSeven(hqBillNearlySevenDayMapper.nearlySevenDay(vo.getSevenMark()));
        return data;
    }
}
